package com.zyf.system.db.mysql;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zyf.system.controller.dto.ScheduleAddDto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;

/**
 * @author 张云帆
 * 2025/3/25 10:05
 * 排班表
 */
@Entity
@Table(name = "schedule")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Schedule extends BaseEntity{
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    /**
     * 医生id
     */
    @Column(name = "doctor_id")
    private Integer doctorId;

    /**
     * 科室id
     */
    @Column(name = "department_id")
    private Integer departmentId;

    /**
     * 开始时间
     */
    @Column(name = "start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    /**
     * 结束时间
     */
    @Column(name = "end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    /**
     * 最大可挂号数量
     */
    @Column(name = "max_patients")
    private Integer maxPatients;

    /**
     * 当前已挂号数量
     */
    @Column(name = "current_patients")
    private Integer currentPatients;

    public Schedule(ScheduleAddDto scheduleAddDto){
        this.doctorId = scheduleAddDto.getDoctorId();
        this.departmentId = scheduleAddDto.getDepartmentId();
        this.startTime = scheduleAddDto.getStartTime();
        this.endTime = scheduleAddDto.getEndTime();
        this.maxPatients = scheduleAddDto.getMaxPatients();
        this.currentPatients = scheduleAddDto.getCurrentPatients();
    }
}
